package com.pg_chat.model.VO;

import com.pg_chat.model.UserEntity;

import java.sql.Timestamp;
import java.util.Date;

public class UserInfoVO {
    private Integer userId;
    private Integer userState;
    private Short age;
    private Short sex;
    private String username;
    private String emailAddr;
    private String phoneNumber;
    private String signature;
    private String intro;
    private String headPortrait;
    private Date birthday;
    private Timestamp createTime;
    private Date updateTime;

    public UserInfoVO() {
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public Integer getUserState() {
        return userState;
    }

    public void setUserState(Integer userState) {
        this.userState = userState;
    }

    public Short getAge() {
        return age;
    }

    public void setAge(Short age) {
        this.age = age;
    }

    public Short getSex() {
        return sex;
    }

    public void setSex(Short sex) {
        this.sex = sex;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getEmailAddr() {
        return emailAddr;
    }

    public void setEmailAddr(String emailAddr) {
        this.emailAddr = emailAddr;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        StringBuffer encode = new StringBuffer(phoneNumber);
        encode.replace(3,7,"*****");

        this.phoneNumber = encode.toString();
    }

    public String getSignature() {
        return signature;
    }

    public void setSignature(String signature) {
        this.signature = signature;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public String getHeadPortrait() {
        return headPortrait;
    }

    public void setHeadPortrait(String headPortrait) {
        this.headPortrait = headPortrait;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    /**
     * 将数据库的数据转换为用于展示的对象
     * @param user
     * @return
     */
    public static UserInfoVO exchange(UserEntity user){
        UserInfoVO info = new UserInfoVO();
        info.setUserId(user.getUserId());
        info.setUserState(user.getUserState());
        info.setAge(user.getAge());
        info.setSex(user.getSex());
        info.setUsername(user.getUsername());
        info.setEmailAddr(user.getEmailAddr());
        info.setBirthday(user.getBirthday());
        info.setPhoneNumber(user.getPhoneNumber());
        info.setSignature(user.getSignature());
        info.setIntro(user.getIntro());
        info.setHeadPortrait(user.getHeadPortrait());
        info.setCreateTime(user.getCreateTime());
        info.setUpdateTime(user.getUpdateTime());

        return info;
    }

}
